<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>渲染列表元素</title>
</head>
<body>
    <div id="change" class="change">
        <ul>
           <li data-for="['durant', 'kobe', 'james', 'curry']"></li>
        </ul>
    </div>

    <script>
        let element = document.querySelector("ul > li")
        console.log(element);
        
        let parent = element.parentNode
        parent.removeChild(element)

        if (element.hasAttribute("data-for")) {
            let attribute = element.getAttribute("data-for")
            console.log(attribute);
            let array = eval(attribute)

            for (let index = 0; index < array.length; index++) {
                const content = array[index];
                console.log(content);


                let child = document.createElement(element.tagName)
                child.textContent = content
                parent.appendChild(child)
                
            }
            
        }
    </script>
</body>
</html>